package com.example.test.handler;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class TraceHandler implements InvocationHandler {

    private Object target;

    public TraceHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(target);
        System.out.println("."+method.getName()+"(");
        if (args != null){
            for (int i = 0;i<args.length;i++){
                System.out.println(args[i]+",");
            }
        }
        System.out.println(")");
        return method.invoke(target,args);
    }
}
